package com.jt.redis;

import redis.clients.jedis.Jedis;

public class VoteDemo01 {
    static void vot(String activityId,String userId){
        Jedis jedis = new Jedis("192.168.126.128", 6379);
        Boolean flag = jedis.sismember(activityId, userId);
        if (flag){
            jedis.srem(activityId, userId);
        }else{
            jedis.sadd(activityId, userId);
        }
        System.out.println(jedis.smembers(activityId));
        Long scard = jedis.scard(activityId);
        System.out.println("总共投票人数为："+scard);
        jedis.close();
    }
    public static void main(String[] args) {
        vot("vot","tom");
    }
}
